#include "parse_args.h"
char *log_file = NULL;
char *diff_so_file = NULL;
char *img_file = NULL;
int   difftest_port = 1234;
char *elf_file = NULL;
extern void sdb_set_batch_mode();
 int parse_args(int argc, char *argv[]) {
  const struct option table[] = {
    {"batch"    , no_argument      , NULL, 'b'},
    {"log"      , required_argument, NULL, 'l'},
    {"diff"     , required_argument, NULL, 'd'},
    {"port"     , required_argument, NULL, 'p'},
    {"help"     , no_argument      , NULL, 'h'},
    {"elf"      , required_argument, NULL, 'e'},
  	{"img"     , required_argument , NULL, 'i'},
    {0          , 0                , NULL,  0 },
  };
  int o;
	while ( (o = getopt_long(argc, argv, "-bhl:d:p:e:", table, NULL)) != -1) {
		switch (o) {
			case 'b': sdb_set_batch_mode(); break;
			case 'p': sscanf(optarg, "%d", &difftest_port); break;
			case 'l': log_file = optarg; break;
			case 'd': diff_so_file = optarg; break;
			case 'e': elf_file = optarg; break;
			case 'i': img_file = optarg;break;
			default:
				printf("Usage: %s [OPTION...] IMAGE [args]\n\n", argv[0]);
				printf("\t-b,--batch              run with batch mode\n");
				printf("\t-l,--log=FILE           output log to FILE\n");
				printf("\t-d,--diff=REF_SO        run DiffTest with reference REF_SO\n");
				printf("\t-p,--port=PORT          run DiffTest with port PORT\n");
				printf("\n");
				exit(0);
		}
  }
  return 0;
}